package com.bjpowernode.controller;

import com.bjpowernode.mapper.AdminMapper;
import com.bjpowernode.pojo.Admin;
import com.bjpowernode.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequestMapping("admin")
public class AdminController {

    @Autowired
    public AdminService adminService;

    @RequestMapping("login")
    public String login(String name, String pwd, Model model){
        Admin admin = adminService.login(name, pwd);
        if (admin != null){
            model.addAttribute("admin",admin);
            return "main";
        }else {
            model.addAttribute("errmsg","账号密码错误");
            return "login";
        }

    }


}
